Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(maven): do not track registries when fetching requirements #1466

Merged
merged 4 commits into from
Jan 6, 2025

Conversation

cuixq
Copy link
Contributor

@cuixq cuixq commented Dec 23, 2024

#1447

When fetching requirements of a Maven dependency, we should not keep track of the registries defined in pom.xml of dependencies. Doing that will add a lot irrelevant registries to the client and sends unnecessary requests, and finally slows down the resolution.

This PR also disables PreFetch in Maven transitive scanning. PreFetch calls MatchVersions which sends requests to maven-metadata.xml for native Maven client. maven-metadata.xml is not necessarily needed for all dependencies. Disabling PreFetch will save us from making requests to these files. However, calling PreFetch should be fine for deps.dev client, and this can be a TODO in the future.

With this fix, resolving pom.xml is now shortened to 10-20 seconds.

@codecov-commenter
Copy link

codecov-commenter commented Dec 23, 2024

Codecov Report

Attention: Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 67.08%. Comparing base (9d28c7f) to head (c422c68).

Files with missing lines Patch % Lines
...nternal/resolution/client/maven_registry_client.go 33.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1466      +/-   ##
==========================================
- Coverage   67.32%   67.08%   -0.24%     
==========================================
  Files         192      192              
  Lines       18161    18164       +3     
==========================================
- Hits        12226    12185      -41     
- Misses       5283     5324      +41     
- Partials      652      655       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cuixq cuixq changed the title fix(maven): do not add registries when fetching requirements fix(maven): do not track registries when fetching requirements Dec 23, 2024
@cuixq cuixq marked this pull request as ready for review December 23, 2024 03:10
@@ -132,7 +132,8 @@ func (e Extractor) Extract(ctx context.Context, input *filesystem.ScanInput) ([]
}
overrideClient.AddVersion(root, reqs)

client.PreFetch(ctx, overrideClient, reqs, filepath.Join(input.Root, input.Path))
// TODO: only run `PreFetch` for deps.dev client
// client.PreFetch(ctx, overrideClient, reqs, filepath.Join(input.Root, input.Path))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the impact on performance of this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this depends on which registry client we are using, for this pom.xml:

  • with deps.dev client: the performance is worse, with runtime from 20s to 1m
  • with native registry: the runtime improved from more than 10m to 10s

for reference, it takes mvn about 25s to resolve without any local cache.

Copy link
Member

@michaelkedar michaelkedar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - we can revisit whether prefetching some endpoints works for the native maven client in future.

@cuixq cuixq merged commit a3ce0d0 into google:main Jan 6, 2025
13 checks passed
@cuixq cuixq deleted the maven branch January 6, 2025 04:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants